package com.ash;

import JavaAPI.CofInfo;
import JavaAPI.HttpsPostRequest;
import JavaAPI.Receipt;
import JavaAPI.ResPurchaseCC;
import com.ash.service.TransactionService;

public class TestPurchaseWithVault {


    public static void main(String[] args) {
        TransactionService transactionService = TransactionService.getInstance();
        HttpsPostRequest mpgReq = transactionService.getHttpsPostRequest();

        java.util.Date createDate = new java.util.Date();
        String order_id = "Test" + createDate.getTime();
        String data_key = "2qHsKNh7IOUaYkhDuhn9ukB72";
        String amount = "1.00";
        String cust_id = "ootdbuy"; //if sent will be submitted, otherwise cust_id from profile will be used
        String crypt_type = "1";


        ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
        resPurchaseCC.setData(data_key);
        resPurchaseCC.setOrderId(order_id);
        resPurchaseCC.setCustId(cust_id);
        resPurchaseCC.setAmount(amount);
        resPurchaseCC.setCryptType(crypt_type);
        //resPurchaseCC.setDynamicDescriptor(descriptor);
        //resPurchaseCC.setExpDate(expdate); //Temp Tokens only

        //Mandatory - Credential on File details
        CofInfo cof = new CofInfo();
        cof.setPaymentIndicator("U");
        cof.setPaymentInformation("2");
        cof.setIssuerId("139X3130ASCXAS9");

        resPurchaseCC.setCofInfo(cof);

        mpgReq.setTransaction(resPurchaseCC);

        mpgReq.send();

        try {
            Receipt receipt = mpgReq.getReceipt();

            System.out.println("DataKey = " + receipt.getDataKey());
            System.out.println("ReceiptId = " + receipt.getReceiptId());
            System.out.println("ReferenceNum = " + receipt.getReferenceNum());
            System.out.println("ResponseCode = " + receipt.getResponseCode());
            System.out.println("AuthCode = " + receipt.getAuthCode());
            System.out.println("Message = " + receipt.getMessage());
            System.out.println("TransDate = " + receipt.getTransDate());
            System.out.println("TransTime = " + receipt.getTransTime());
            System.out.println("TransType = " + receipt.getTransType());
            System.out.println("Complete = " + receipt.getComplete());
            System.out.println("TransAmount = " + receipt.getTransAmount());
            System.out.println("CardType = " + receipt.getCardType());
            System.out.println("TxnNumber = " + receipt.getTxnNumber());
            System.out.println("TimedOut = " + receipt.getTimedOut());
            System.out.println("ResSuccess = " + receipt.getResSuccess());
            System.out.println("PaymentType = " + receipt.getPaymentType());
            System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
            System.out.println("Cust ID = " + receipt.getResCustId());
            System.out.println("Phone = " + receipt.getResPhone());
            System.out.println("Email = " + receipt.getResEmail());
            System.out.println("Note = " + receipt.getResNote());
            System.out.println("Masked Pan = " + receipt.getResMaskedPan());
            System.out.println("Exp Date = " + receipt.getResExpdate());
            System.out.println("Crypt Type = " + receipt.getResCryptType());
            System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
            System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
            System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
            System.out.println("IssuerId = " + receipt.getIssuerId());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
